// 这就是一个高阶组件
import { useState } from 'react'

// 传入一个组件
export const WithCounter = (OriginalComponent: any) => {
  // 返回组件
  const NewComponent = () => {
    const [count, setCount] = useState(0)
    const incrementCount = () => {
      setCount(count + 1)
    }
    return <OriginalComponent count={count} incrementCount={incrementCount} />
  }
  return NewComponent
}
